﻿<!--#include file="const.inc"-->
<%
'====================================================================
' 感谢使用晴天3G智能建站系统..
' 作者:梁永强.QQ:766750857
' 官方网址:wap.qt3g.com
' 声明:软件版权归作者所有,没有经过作者本人同意不得非法破解和传播本程序
'====================================================================
%>
<%
if sid="Null" then Response.Redirect "/login.asp?sid="&sidd&"&url=/game/wulon/index.asp"
IF  Request.QueryString("Action")="login" Then
	call loginn
else
	call index
end if
end Function

Function index
        dim pid,mon,body
	pid=Request.QueryString("pid")
	if pid="" then pid=1
	if not isnumeric(pid) then pid=1
	pid=clng(pid)
        mon=sangong.namejian("money",pid)
select case v
case "0"
we0="<br/>"
hr="----------------<br/>"
body="下注<a href='gamedd.asp?pid="&pid&"&amp;mid="&int(mon/5)&"&amp;Action=login&amp;sid=" & sidd & "'>"&int(mon/5)&"</a>.<a href='gamedd.asp?pid="&pid&"&amp;mid="&int(mon/2)&"&amp;Action=login&amp;sid=" & sidd & "'>"&int(mon/2)&"</a>.<a href='gamedd.asp?pid="&pid&"&amp;mid="&mon&"&amp;Action=login&amp;sid=" & sidd & "'>"&mon&"</a><br/><input name='mid' format='*N' size='15' maxlength='10'/><br/>最高不能超过"&mon&"<br/><anchor>下注<go href='gamedd.asp?pid="&pid&"&amp;Action=login&amp;sid="&sidd&"' method='post'><postfield name=""mid"" value=""$(mid:n)"" /></go></anchor><br/>"
%>
<card id="main" title="疯狂牛牛"><p align="<%=qingtian.px%>">
<%
case "1"
zi="<span style=""color:#FF5500"">"
zi0="</span>"
we="<div class=""footer"">"
sou="<div class=""block4"">"
dao="<div class=""navi"">"
we0="</div>"
we1="</div>"
ziz="<div style=""background-color:#FF5226;font-size:16px;color:#E1E100"">"
body="<div class=""footer"">下注<a href='gamedd.asp?pid="&pid&"&amp;mid="&int(mon/5)&"&amp;Action=login&amp;sid=" & sidd & "'>"&int(mon/5)&"</a>.<a href='gamedd.asp?pid="&pid&"&amp;mid="&int(mon/2)&"&amp;Action=login&amp;sid=" & sidd & "'>"&int(mon/2)&"</a>.<a href='gamedd.asp?pid="&pid&"&amp;mid="&mon&"&amp;Action=login&amp;sid=" & sidd & "'>"&mon&"</a></div><form action='gamedd.asp?pid="&pid&"&amp;Action=login&amp;sid="&sidd&"' method='post'><input emptyok='true' format='*N' type='text' name='mid' value='' size='15'/><br/><div class=""block4"">最高不能超过"&mon&"</div><input type='submit' value='下注'/></form><br/>"
%>
<title>疯狂牛牛</title>
</head>
<body>
<!--#include virtual="/css.inc"-->
<%
End Select
%>
<%=ziz%>★★我要下注★★<%=we0%><%=body%>
<%=we%>账户:<%=zi%><%=conn.execute("select money from [qingtian_user] where sid='"&qingtian.Formatsid(sid)&"'")("money")%><%=qingtian.bi%><%=zi0%><%=we0%><%=sou%>
<a href="main2.asp?sid=<%=sidd%>">返回上级</a>.<a href="/game/wulon/index.asp?sid=<%=sidd%>">疯狂牛牛</a><%=we0%>

<%
end Function

Function loginn
dim id,a,b,nid,rs,sql,i,d,rss,sqls,mynid,mon,mid,pid
	pid=Request.QueryString("pid")
	if pid="" then pid=1
	if not isnumeric(pid) then pid=1
	pid=clng(pid)
	id=100000
mynid=qingtian.nid
if Request.QueryString("act")=2 then
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 * FROM qingtian_reton where nid="&mynid&" order by id asc"
	Rs.Open Sql,cn,1,3
		if not (rs.bof and rs.eof)  then 
                rs("ton")=0
                rs("time")=now()
                rs("aid")=0
	rs.update
        end if
	Rs.close
       set rs=nothing
Response.Redirect "fangd.asp?sid="&sidd&"&id="&pid
end if
select case v
case "0"
we0="<br/>"
hr="----------------<br/>"
%>
<card id="main" title="疯狂牛牛"><p align="<%=qingtian.px%>">
<%
case "1"
zi="<span style=""color:#FF5500"">"
zi0="</span>"
we="<div class=""footer"">"
sou="<div class=""block4"">"
dao="<div class=""navi"">"
we0="</div>"
we1="</div>"
ziz="<div style=""background-color:#FF5226;font-size:16px;color:#E1E100"">"
%>
<title>疯狂牛牛</title>
</head>
<body>
<!--#include virtual="/css.inc"-->
<%
End Select
        mon=sangong.namejian("money",pid)
	mid=Request("mid")
	if mid="" then mid=10
	if not isnumeric(mid) then mid=10
	mid=clng(mid)
        if mid>mon then qingtian.err("下注金额不能超过"&mon&"")
qingtian.info
toname=cn.execute("select toname from [qingtian_fangjian] where id="&pid&"")("toname")
if sangong.namere("aid",mynid)<>0 and sangong.namere("aid",mynid)<>id then
qingtian.err("你还在游戏中<a href='gamed.asp?pid="&pid&"&amp;id="&sangong.namere("aid",mynid)&"&amp;sid=" & sidd & "'>返回继续游戏</a>")
end if 
sangong.pd(pid)
%>
<%=ziz%>☆疯狂牛牛☆<%=we0%>
<%=dao%><%=toname%> ＰＫ　<%=qingtian.utf8(session("username"))%><%=we0%><%=hr%><%=we%>
<%

	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 * FROM qingtian_reton where nid="&mynid&" order by id asc"
	Rs.Open Sql,cn,1,3
		if not (rs.bof and rs.eof)  then 
                rs("ton")=1
                rs("time")=now()
                rs("aid")=id
                rs("bid")=pid
	rs.update
        end if
	Rs.close
        set rs=nothing
       sangong.gameed(pid) 
                a=clng(session("a"))
                b=clng(session("b"))
                nid=0
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select * FROM qingtian_reton where aid="&id&" and ton<>2 order by nid asc"
	Rs.Open Sql,cn,1,3
		if not (rs.bof and rs.eof)  then
                lui=sangong.namejian("pid",pid)
 		For i=1 to rs.RecordCount
                if rs("a") > a then
                if rs("a")=100 then
                mid=mid*5
                elseif rs("a")>6 and rs("a")<>10 then
                mid=mid*2
                elseif rs("a")=10 then
                mid=mid*3
                end if
                rs("m")=rs("m")+int(mid)*(1-lui/100)
                rs("shen")=rs("shen")+1
                rs("d")=int(mid)*(1-lui/100)
                qingtian.pay int(mid)*(1-lui/100),rs("nid")
                d=int(mid)*(1-lui/100)+d 
                elseif rs("a") < a then
                if a=100 then
                mid=mid*5
                elseif a>6 and a<>10 then
                mid=mid*2
                elseif a=10 then
                mid=mid*3
                end if
                rs("m")=rs("m")-int(mid)
                rs("shu")=rs("shu")+1
                rs("d")=-int(mid)
                qingtian.pay -int(mid),rs("nid")
                d=d-100 
                else
                if a=100 then
                mid=mid*5
                elseif a>6 and a<>10 then
                mid=mid*2
                elseif a=10 then
                mid=mid*3
                end if
                if rs("b") > b then
                rs("m")=rs("m")+int(mid)*(1-lui/100)
                rs("shen")=rs("shen")+1
                rs("d")=int(mid)*(1-lui/100)
                qingtian.pay int(mid)*(1-lui/100),rs("nid") 
                d=int(mid)*(1-lui/100)+d 
                else
                rs("m")=rs("m")-int(mid)
                rs("shu")=rs("shu")+1
                rs("d")=-int(mid)
                qingtian.pay -int(mid),rs("nid")
                d=d-int(mid)
                end if
                end if 
	        rs.update                            
		Rs.MoveNext
		next
                end if
       Rs.close
       set rs=nothing                 
          if sangong.namere("d",mynid)<0 then
          Response.Write("很遗憾你输了,系统自动扣除你"&zi&""&abs(sangong.namere("d",mynid))&""&qingtian.bi&""&zi0&"!<br/>") 
          qingtian.addong("在游戏[url=/game/wulon/index.asp?sid=[sid]]牛牛[/url]中输掉了"&qingtian.bi&"")        
          else
          Response.Write("恭喜,你赢了系统为你增加"&zi&""&sangong.namere("d",mynid)&""&qingtian.bi&""&zi0&"!<br/>") 
          qingtian.addong("在游戏[url=/game/wulon/index.asp?sid=[sid]]牛牛[/url]中赢得了"&qingtian.bi&"")   
          end if
                if a=100 then
                aaa="五龙"
                elseif a=0 then
                aaa="无牛"
                elseif a=10 then
                aaa="牛牛"
                else
                aaa="牛"&a
                end if
          Response.Write(""&toname&"的牌"&zi&"(庄)"&zi0&"："&zi&""&aaa&""&zi0&"<br/>"&sangong.pai(session("c"))&"<br/>")  
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select * FROM qingtian_reton where aid="&id&" order by id asc"
	Rs.Open Sql,cn,1,1
		if not (rs.bof and rs.eof)  then
 		For i=1 to rs.RecordCount
                if rs("nid")=mynid then
                tt="你的"
                else
                tt=qingtian.name(rs("nid"))
                end if
                if rs("a")=100 then
                aa="五龙"
                elseif rs("a")=0 then
                aa="无牛"
                elseif rs("a")=10 then
                aa="牛牛"
                else
                aa="牛"&rs("a")
                end if
                Response.Write(""&tt&"的牌："&zi&""&aa&""&zi0&"<br/>"&sangong.pai(rs("c"))&"<br/>")                
		Rs.MoveNext
		next
                end if
       Rs.close
       set rs=nothing 
          Response.Write("是否继续游戏:<br/>1.<a href='gamedd.asp?pid="&pid&"&amp;sid="&sidd&"'>继续</a><br/>2.<a href='gamedd.asp?act=2&amp;Action=login&amp;sid="&sidd&"'>退出</a><br/>")
	Set Rs = Server.CreateObject("Adodb.Recordset")
	Sql = "select top 1 * FROM qingtian_reton where nid="&mynid&" order by id asc"
	Rs.Open Sql,cn,1,3
		if not (rs.bof and rs.eof)  then 
                rs("ton")=0
                rs("time")=now()
                rs("aid")=0
	rs.update
        end if
	Rs.close
        set rs=nothing
%>
<%=we1%><%=hr%><%=sou%>账户:<%=zi%><%=conn.execute("select money from [qingtian_user] where sid='"&qingtian.Formatsid(sid)&"'")("money")%><%=zi0%><%=qingtian.bi%><%=we0%><%=ziz%><a href="main2.asp?sid=<%=sidd%>">返回上级</a>.<a href="/game/wulon/index.asp?sid=<%=sidd%>">疯狂牛牛</a><%=we0%>

<%
end function
%>